<!DOCTYPE html>
<html>
<head></head>
<body>
  <canvas id="myCanvas" width="512" height="256"></canvas>
</body>
<script>
var canvas = document.getElementById("myCanvas");

var ctx = canvas.getContext('2d');
ctx.fillStyle = "green";
ctx.fillRect(canvas.width/2, 0, canvas.width/2, canvas.height);

</script>
</html>